package com.kborid.musicplayer;

import java.io.File;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Window;
import android.widget.ImageView;

import com.kborid.musicplayer.Control.ActivityBase;
import com.kborid.musicplayer.Control.AndroidApp;
import com.kborid.musicplayer.Tools.EnvironmentDir;

public class ACT_Launcher extends ActivityBase {

	private static final String TAG = "ACT_Launcher";
	private static final String BG = "mm";
	private ImageView iv_bg;

	private Handler myHandler = new Handler() {
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 0:
				Log.i(TAG, "context = " + AndroidApp.getContext());
				Intent intent = new Intent();
				intent.setClass(ACT_Launcher.this, ACT_Main_MusicPlayer.class);
				startActivity(intent);
				overridePendingTransition(R.anim.alpha_in, R.anim.alpha_out);
				finish();
				break;
			}
		};
	};

	@Override
	protected void OnCreate(Bundle savedInstanceState) {
		super.OnCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.act_launcher);
		iv_bg = (ImageView) findViewById(R.id.iv_bg);
		File f = new File(EnvironmentDir.getInstance().getCacheDirectory() + "/" + BG + ".png");
		if (f.exists()) {
			BitmapDrawable dw = new BitmapDrawable(f.toString());
			iv_bg.setBackground(dw);
		} else {
			iv_bg.setBackgroundColor(Color.YELLOW);
		}
	}

	@Override
	protected void OnResume() {
		super.OnResume();
		myHandler.sendEmptyMessageDelayed(0, 1000);
	}

	@Override
	protected void OnDestroy() {
		super.OnDestroy();
	}
}
